package com.jdwx.opengl.kotlin2

fun main(){
    val list6 = listOf(0,1, 2, 3, 4, 5, 6,7,8,9)

    var iterator = list6.iterator()

    while (iterator.hasNext()){
        println( iterator.next() )
    }

    list6.forEach{
        it * it
        print( it )
    }

    println( list6 )
    val mutableList = mutableListOf(1,2,3)

    mutableList.add( 0,10 )
    mutableList.addAll(listOf(1,2,3,4))
    //mutableList.removeAt(1)
    //mutableList.removeAll( listOf(1,2) )
    //mutableList.clear()
    println( mutableList )
    var li = mutableList.toList()
    println( li.first() )
    println( li.firstOrNull() )
    li.firstOrNull({it==100})

    var result = li.foldRight(100,{total, s -> s+total})
    println( "result:$result")

    val list = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

    list.forEach { value -> if (value > 7) println(value) }

    list.forEachIndexed{index,value->if (value>8) print("value $index=$value") }



}